package com.zhss.springbootdemo01.mapper;

import com.zhss.springbootdemo01.domain.User;
import org.apache.ibatis.annotations.*;

import java.util.List;

/**
 * @ClassName UserMapper
 * @Description TODO
 * @Author leejiliang
 * @DateTime 2021/2/6 18:04
 * @Version 1.0
 */
@Mapper
public interface UserMapper {

	@Select("select * from user")
	List<User> listUser();

	@Select("SELECT * FROM user WHERE id = #{userId}")
	User getUserById(@Param("userId") Long userId);

	@Insert("INSERT INTO user(name, age) VALUES(#{name}, #{age})")
	void saveUser(User user);

	@Update("UPDATE user SET name=#{name}, age=#{age} WHERE id=#{id}")
	void updateUser(User user);

	@Delete("DELETE FROM user WHERE id=#{userId}")
	void removeUser(@Param("userId") Long userId);

}
